package org.whatever.aha.zjut.platform.mapper.school;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.whatever.aha.zjut.platform.entity.school.ProjectScore;

/**
 * @author Vc
 * @version 1.0
 * @Desc
 * @date 2021/11/22 0:57
 */
public interface ProjectScoreMapper extends BaseMapper<ProjectScore> {

    @Select("SELECT COUNT(*) FROM " +
            "(SELECT project_id FROM project WHERE project_tag = #{tag} AND project_delete_status = 0 AND project_school_status != 3) AS project_info " +
            "INNER JOIN " +
            "(SELECT project_id FROM project_score WHERE stage_id = #{stageId} AND judge_id = #{judgeId}) AS project_score_info " +
            "ON project_info.project_id = project_score_info.project_id")
    int getAlreadyJudgeNum(@Param("stageId") int stageId,@Param("judgeId") int judgeId,@Param("tag") String tag);

    @Select("SELECT COUNT(*) FROM " +
            "(SELECT project_id FROM project WHERE project_group = #{groupName} AND stage_id = #{stageId} AND project_delete_status = 0) AS project_info " +
            "INNER JOIN " +
            "(SELECT project_id FROM project_score WHERE stage_id = #{stageId} AND judge_id = #{judgeId}) AS project_score_info " +
            "ON project_info.project_id = project_score_info.project_id")
    Integer getAlreadyJudgedProjectNum(@Param("stageId")int stageId, @Param("groupName")String groupName, @Param("judgeId")int judgeId);
}
